#include "lcd.h"

void fb_DrawLine(short x1, short y1, short x2, short y2, int color)
{
  int i = 0;
  int d = 0;
  
  if (abs(y2-y1) > abs(x2-x1)){
    d = (y2 > y1) ? 1 : -1;
    for (i = y1; i != y2; i += d){
      fb_PutPixel(x1+(i-y1)*(x2-x1)/(y2-y1), i, color);
    }
  }
  else{
    d = (x2 > x1) ? 1 : -1;
    for (i = x1; i != x2; i += d){
      fb_PutPixel(i, y1+(i-x1)*(y2-y1)/(x2-x1), color);
    }
  }
}
